package com.example.springboot.mapper;


import com.example.springboot.pojo.Repair;
import org.apache.ibatis.annotations.*;

@Mapper
public interface RepairMapper {

    @Select("select * from repair order by time desc")
    Repair[] getAllRepair();

    @Select("select * from repair where room_number=#{roomNumber} order by time desc")
    Repair[] getByRoomNumber(String roomNumber);

    @Select("select * from repair where worker_id=#{workerId} order by time desc")
    Repair[] getByWorkerId(String workerId);

    @Delete("delete from repair where id=#{id}")
    void deleteRepair(Integer id);

    @Update("update repair set status=1,worker_id=#{workerId} where id=#{id}")
    void passRepair(Integer id,String workerId);

    @Update("update repair set status=2 where id=#{id}")
    void finishRepair(Integer id);

    @Insert("insert into repair(room_number,detail,photo,time) values(#{roomNumber},#{detail},#{photo},#{time})")
    void addRepair(String roomNumber, String detail,String photo,String time);

    @Select("select * from repair where id=#{id}")
    Repair findRepair(Integer id);
}
